Skip to content

fix(arg-parsing): allow project display names with spaces in org/project argument#1116

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/arg-parsing-project-display-names
Open

fix(arg-parsing): allow project display names with spaces in org/project argument#1116
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/arg-parsing-project-display-names

Conversation

@sentry

@sentry sentry Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

This PR addresses CLI-1RA, where sentry issue list (and other commands using parseOrgProjectArg) would throw a ValidationError when a project display name containing spaces was provided in the org/project argument format (e.g., sentry/My Project).

The root cause was an inconsistency in src/lib/arg-parsing.ts. While bare project slugs (My Project) and leading-slash project slugs (/My Project) correctly fell back to a fuzzy display-name search when spaces were detected, the explicit org/project path in parseSlashOrgProject directly called validateResourceId, which strictly rejects spaces.

This fix aligns the behavior across all input forms:

  1. src/lib/arg-parsing.ts: In parseSlashOrgProject, if the project segment of an org/project argument contains spaces (i.e., looksLikeDisplayName is true), it now returns a project-search type, preserving the provided organization slug.
  2. src/lib/arg-parsing.ts: The ParsedOrgProject type's project-search variant was updated to include an optional org field to carry this context.
  3. src/lib/resolve-target.ts: In resolveOrgProjectTarget, the display-name based project search (isDisplayName path) now filters the list of organizations to search within if an org is provided in the project-search object, ensuring the search remains scoped to the user's explicit organization.

Fixes CLI-1RA

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1116/

Built to branch gh-pages at 2026-06-20 22:45 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.

Comment thread src/lib/resolve-target.ts
isDisplayName && parsed.org !== undefined
? foundOrgs.filter((o) => o.slug === parsed.org)
: foundOrgs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue list ignores display names

High Severity

Parsing now emits project-search with originalSlug for org/<display name>, but resolveTargetsFromParsedArg still only calls findProjectsBySlug and slug-pattern fallbacks. It never uses display-name triage, so sentry issue list (and similar list commands) keep failing after the parse fix.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.

Comment thread src/lib/resolve-target.ts
const orgs =
isDisplayName && parsed.org !== undefined
? foundOrgs.filter((o) => o.slug === parsed.org)
: foundOrgs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Org scope ignored in fuzzy search

Medium Severity

project-search now carries optional org for org/<display name>, and only resolveOrgProjectTarget filters organizations before fuzzy matching. resolveProjectBySlug, handleProjectSearch, and similar paths still search all accessible orgs, so an explicit org prefix may resolve to the wrong project.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.

Comment thread src/lib/resolve-target.ts
Comment on lines +1643 to 1646
const { projects, orgs: foundOrgs } = isDisplayName
? { projects: [], orgs: await listOrganizations() }
: await findProjectsBySlug(parsed.projectSlug);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The resolveTargetsFromParsedArg function doesn't handle project display names (e.g., "My Project") when an organization is specified, causing commands like sentry issue list to fail.
Severity: MEDIUM

Suggested Fix

The logic for handling display names from resolveOrgProjectTarget should be mirrored in the project-search case within resolveTargetsFromParsedArg. Specifically, it should check if the project identifier is a display name and, if so, skip the findProjectsBySlug call and proceed directly to the fuzzy matching logic, ensuring the search is correctly scoped to the provided organization.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/lib/resolve-target.ts#L1643-L1646

Potential issue: The `resolveTargetsFromParsedArg` function, used by commands like
`sentry issue list`, does not correctly handle project searches that use a display name
containing spaces (e.g., `sentry/"My Project"`). The code enters the `project-search`
case and calls `findProjectsBySlug` with the display name, which is not a valid slug and
causes the search to fail. The logic to handle display names by skipping
`findProjectsBySlug` and performing fuzzy matching was implemented in
`resolveOrgProjectTarget` but was missed in `resolveTargetsFromParsedArg`, leading to
inconsistent behavior and command failure for this use case.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants